const path = require("path");
const {CleanWebpackPlugin} = require("clean-webpack-plugin");

module.exports = {
    entry: "./src/index.js",
    output: {
        filename: "lx.js",
        path: path.resolve(__dirname, "dist")
    },
    module: {
        rules: [{
            test: /\.css$/,
            use: ["style-loader", "css-loader"]
        }, {
            test: /\.(jpg|png|svg|gif)$/,
            // type: 'asset/source',
            use: {
                loader: "url-loader",
                options: {
                    limit: 10 * 1024,
                    esModule: false
                },
            },
            type: 'javascript/auto'
        }, {
            test: /\.js$/,
            use: {
                loader: "babel-loader",
                options: {
                    presets: ["@babel/preset-env"]
                }
            }
        }, {
            test: /\.html$/,
            use: {
                loader: "html-loader",
                options: {
                    sources: {
                        list: [
                            {
                                tag: "a",
                                attribute: "href",
                                type: "src"
                            },
                            {
                                tag: "img",
                                attribute: "src",
                                type: "src"
                            }
                        ]
                    }
                }
            }
        }]
    },
    plugins: [new CleanWebpackPlugin()],
    mode: "none"
}